package com.jyb.controller;

import java.util.ArrayList;
import java.util.List;

import com.jfinal.core.Controller;
import com.jyb.model.MyOrder;
import com.jyb.model.QueryLog;
import com.jyb.util.StringUtils;
import com.jyb.util.capture.YpcdUtil;
import com.jyb.vo.UserVo;
import com.jyb.vo.YpcdVo;

/**
 * 预配仓单
 * @author wangsanfei
 *
 */
public class YpcdController extends Controller{

	public void index(){
		
		String tdh=getPara("tdh");
		List<YpcdVo> vos=new ArrayList<YpcdVo>();
		if(!StringUtils.isEmpty(tdh)){
			tdh=tdh.trim();
			vos=YpcdUtil.capture(tdh);
		}
		
		UserVo userVo=(UserVo)getSession().getAttribute("user");
		if(userVo!=null){
			for (YpcdVo ypcdVo : vos) {
				MyOrder.dao.updateMyOrder(userVo.getId(), tdh, ypcdVo.getCm(), ypcdVo.getCc());
			}
		}
		
		if(userVo!=null&&vos.size()>0){
			QueryLog.dao.addOrUpdate(userVo.getId(), "1", tdh);
		}
		
		setAttr("tdh", tdh);
		setAttr("vos", vos);
		
		setAttr("nav", "ypcd");
		renderJsp("/views/ypcd/index.jsp");
	}
}
